/**
 * 功能描述 列表
 */
define(function (require, exports, module) {
	var Grid = require("grid"); 	
	var aw = require("ajaxwrapper")
	var store =require("store");
	var activeUser = store.get("user");
	var Dialog = require("dialog");
	

    var instance = {
        initComponent: function (params, widget) {
        	var grid = new Grid({
        		autoRender:true,
                parentNode : ".J-grid",
                url : "api/customer/queryAllIntention",
                params : function(){
                		var obj={
                				"visitTime":widget.get("subnav").getValue("visitTime").start,
                				"visitTimeEnd":widget.get("subnav").getValue("visitTime").end,
    	     					fetchProperties:"pkProductType,productName,productTypeName," 
    	     							+"pkProduct,wantToBuyNumber,interestNumber,sameasNumber,noInterestNumber,contractNumber"
                		}
                		return obj;
                },
                model : {
                    columns : [{
                    	name : "productName",
                    	label : "产品"
					},{
						name : "productTypeName",
                    	label : "产品类型"
					},{
						name : "wantToBuyNumber",
                    	label : "希望购买",
                    	format : "detail",
                    	formatparams: {
                    		key: "wantToBuyNumber",
                    		handler: function(index,data,rowEle){
                    			if(!data.wantToBuyNumber){
                    				Dialog.alert({
                    					tip: "提示",
                    					content : "该客户暂无回访记录"
                    				})
                    			}else{widget.openView({
                    				url : "eling/elcms/travel/returnvisit/src/returnvisit_main",
                    				params: {
	                    				"business": "skip",
	                    				"productType":{key:data.pkProductType,value:data.productTypeName},
	                    				"product":{key:data.pkProduct,value:data.productName},
	                    				"status":"WantToBuy",
	                    			},
	                    			isAllowBack:true
                    			})
                    			}
                    		}
                    	}
					},{
						name : "interestNumber",
                    	label : "感兴趣",
                    	format : "detail",
                    	formatparams: {
                    		key: "interestNumber",
                    		handler: function(index,data,rowEle){
                    			widget.openView({
                    				url : "eling/elcms/travel/returnvisit/src/returnvisit_main",
                    				params: {
	                    				"business": "skip",
	                    				"productType":{key:data.pkProductType,value:data.productTypeName},
	                    				"product":{key:data.pkProduct,value:data.productName},
	                    				"status":"Interest",
	                    			},
	                    			isAllowBack:true
                    			})
                    		}
                    	}
					},{
						name : "sameasNumber",
                    	label : "一般",
                    	format : "detail",
                    	formatparams: {
                    		key: "sameasNumber",
                    		handler: function(index,data,rowEle){
                    			widget.openView({
                    				url : "eling/elcms/travel/returnvisit/src/returnvisit_main",
                    				params: {
	                    				"business": "skip",
	                    				"productType":{key:data.pkProductType,value:data.productTypeName},
	                    				"product":{key:data.pkProduct,value:data.productName},
	                    				"status":"SameAs",
	                    			},
	                    			isAllowBack:true
                    			})
                    		}
                    	}
					},{
						name : "noInterestNumber",
                    	label : "不感兴趣",
                    	format : "detail",
                    	formatparams: {
                    		key: "noInterestNumber",
                    		handler: function(index,data,rowEle){
                    			widget.openView({
                    				url : "eling/elcms/travel/returnvisit/src/returnvisit_main",
                    				params: {
	                    				"business": "skip",
	                    				"productType":{key:data.pkProductType,value:data.productTypeName},
	                    				"product":{key:data.pkProduct,value:data.productName},
	                    				"status":"NoInterest",
	                    			},
	                    			isAllowBack:true
                    			})
                    		}
                    	}
					},{
						name : "contractNumber",
                    	label : "签约",
                    	format : "detail",
                    	formatparams: {
                    		key: "contractNumber",
                    		handler: function(index,data,rowEle){
                    			widget.openView({
                    				url : "eling/elcms/travel/signingreturnvisit/src/returnvisit_main",
                    				params: {
	                    				"business": "skip",
	                    				"productType":{key:data.pkProductType,value:data.productTypeName},
	                    				"product":{key:data.pkProduct,value:data.productName},
	                    				"status":"Contract",
	                    			},
                    			})
                    		}
                    	}
					}]
        		},
            });
        	widget.set("grid",grid);
        }
    };
    module.exports = instance;
});
